#include <cassert>
#include <algorithm>
#include <boost/bind.hpp>
#include "car.h"
#include "wheel.h"
namespace GameLogic {

    car::car(int id) : m_id(id),m_speed(0.0f),m_xCurrent(0.0f),
                  m_yCurrent(0.0f),m_currentAction(0),m_ySteer(0.0f),
                  m_total_racing_time(0.0f),
                  m_total_run_length(0.0f){
        m_wheels.reserve(4) ;
    }
    


    void car::update_wheels() {
        std::for_each(m_wheels.begin(),
                      m_wheels.end(),
                      boost::bind(&wheel::update,
                                  _1)) ;
    }
    
    wheel* car::get_wheel(int id) {
        assert(id < m_wheels.size()) ;
        return m_wheels[id].get() ;
    }  

    void car::add_a_wheel(HOBJECT wheel_obj) {
		
		wheel* tempp=new wheel(wheel_obj,this,m_wheels.size());
	    boost::shared_ptr<wheel> new_wheel(tempp) ;
        m_wheels.push_back(new_wheel) ;
    }
}
